package com.bamboo.mcp.server.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

@Component
public class McpServerFilter implements WebFilter {
    private static final String TOKEN_HEADER = "X-TOKEN";
    private static final String TOKEN_VALUE = "1234567890";
    private static final Logger logger = LoggerFactory.getLogger(McpServerFilter.class);
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {

        // 获取请求头中的token值
        String token = exchange.getRequest().getHeaders().getFirst(TOKEN_HEADER);
        logger.info("preHandle: 获取的TOKEN: {}", token);
        return chain.filter(exchange);

    }
}
